package com.mumu.poi.excel;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.FileOutputStream;

/**
 * @author mumu
 * @version 1.0
 * @date 2024/1/8 17:15
 * @describe
 */
public class HeightGenerate {

    /**
     * https://juejin.cn/post/7243612658519408695?searchId=202401081526394960DED361D5B7261361
     *
     * @param args
     * @throws Exception
     */

    public static void main(String[] args) throws Exception {
        //文件路径
        String filePath = "excel/HeightGenerate.xls";
        //创建Excel文件(Workbook)
        HSSFWorkbook workbook = new HSSFWorkbook();

        HSSFSheet sheet = workbook.createSheet("Test");// 创建工作表(Sheet)
        HSSFRow row = sheet.createRow(1);
        HSSFCell cell = row.createCell(1);
        cell.setCellValue("123456789012345678901234567890");
        sheet.setColumnWidth(1, 31 * 256);//设置第一列的宽度是31个字符宽度
        row.setHeightInPoints(50);//设置行的高度是50个点
        FileOutputStream out = new FileOutputStream(filePath);
        //保存Excel文件
        workbook.write(out);

        out.close();//关闭文件流
        System.out.println("OK!");

    }
}
